package com.itheima.project;

import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName 类名
 * @Description 类说明
 */
public class QRCodeDemo {
    // https://route.showapi.com/887-1?showapi_appid=354e234624c741b28fe249e39536223a&showapi_sign=替换自己的值
    @Test
    public void testQRcode(){
        RestTemplate restTemplate = new RestTemplate();
        //生成二维码
        String url = "http://route.showapi.com/887-1" +
                "?showapi_appid=1176034" +
                "&showapi_sign=354e234624c741b28fe249e39536223a"+
                "&content=http://www.itcast.cn"+
                "&size=8" +
                "&imgExtName=png";
        String showApiSring = restTemplate.getForObject(url, String.class);
        JSONObject jsonObject = JSONObject.parseObject(showApiSring);
        String qrcodeUrl = jsonObject.getJSONObject("showapi_res_body").getString("imgUrl");
        System.out.println(qrcodeUrl);
    }
}
